package 扩展二叉树;

import java.util.Scanner;

public class Main {
    static String pre, in = "", post = "";
    static int k;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        pre = scanner.next();
        dfs();
        System.out.println(in);
        System.out.println(post);
    }

    private static void dfs() {
        char ch = pre.charAt(k++);
        if (ch == '.') {
            return;
        }
        dfs();
        in += ch;
        dfs();
        post += ch;
    }
}
